/* $Id: common.js 2437 2006-11-05 15:58:09Z weberliu $ */


/* 检查新订单的时间间隔 */
var NEW_ORDER_INTERVAL = 30000;

/**
 * 开始检查新订单；
 */
function startCheckOrder()
{
  checkOrder()
	window.setInterval("checkOrder()", NEW_ORDER_INTERVAL);
}

/*
 * 检查订单
 */
function checkOrder()
{
  try
  {
  	cp.set_response_type("text");
    cp.call("index.php?act=ajax", "check_order", checkOrderResponse);
  }
  catch (e) {}
}

/**
 * 处理检查订单的反馈信息
 */
function checkOrderResponse(res)
{
  	cp.set_response_type("object");

    if (res == '0,0' || res == '')
    {
      return;
    }

    try
    {
      orders = res.split(',');
      document.getElementById('spanNewOrder').innerHTML = orders[0];
      document.getElementById('spanNewPaid').innerHTML = orders[1];
    	Message.show();
    }
    catch (e) { alert(e); }
}

/**
 * 设置页面宽度
 */
function set_size(w) 
{
	var y_width = document.body.clientWidth
	var s_width = screen.width
	var agent   =navigator.userAgent.toLowerCase();

	if (y_width < w) 
  {
		if (agent.indexOf("msie")!=-1) 
    {
      document.body.style.width = w+ "px";
		} 
    else 
    {
		  document.getElementById("bd").style.width = (w - 10) + 'px';
		}
	} 
}

/**
 * 显示隐藏图片
 * @param   id  div的id
 * @param   show | hide
 */
function showImg(id, act)
{
    if (act == 'show')
    {
        document.getElementById(id).style.visibility = 'visible';
    }
    else
    {
        document.getElementById(id).style.visibility = 'hidden';
    }
}
